package com.example.demo.controller;

import com.example.demo.vo.ResponseMsg;
import com.example.demo.annotation.DecryptRequest;
import com.example.demo.annotation.EncryptResponse;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/home")
@EncryptResponse
@DecryptRequest
public class HomeController {


    @GetMapping("/index")
    public ResponseMsg<String> index(String id) {
        return ResponseMsg.ok("111-" + id);
    }


    @PostMapping("/about")
    public ResponseMsg<Map<String, String>> about(@RequestBody Map<String, String> map) {
        Map<String, String> result =new HashMap<>();
        map.keySet().stream().forEach(x -> result.put(x,map.get(x)));
        return ResponseMsg.ok(result);
    }

    @GetMapping("/test")
    public ResponseMsg<String> test() {
        return ResponseMsg.ok("hello");
    }

    @GetMapping("/map")
    public ResponseMsg<Map<String, String>> map() {

        Map<String, String> result =new HashMap<>();
        for (int i = 0; i < 10; i++) {
            result.put(String.valueOf(i),"xx_"+i);
        }
        return ResponseMsg.ok(result);
    }
}
